import Types from '../types';
import DataStore from '../../public/dao/DataStore';
import {handleData} from '../ActionUtil'
export function getLoanData(storeName,data,needRefresh){
    return dispatch =>{
        dispatch({type: Types.LOAN_DATA_LIST_REFRESH, storeName: storeName});
        let dataStore = new DataStore();
        dataStore.fetchData('/webservice/loan',data,'POST',`HomeData${data.loantype}`,true,needRefresh).then((json)=>{
            handleData(Types.LOAN_DATA_LIST_SUCCESS,dispatch,storeName,json,data.loantype);
        }).catch((err)=>{
            dispatch({
                type:Types.LOAN_DATA_LIST_FAIL,
                storeName,
                err
            })
        })
    }
}